package cn.straosp.workrecord.util

import cn.straosp.workrecord.bean.ErrorMessage

sealed class Result<out  T> {
    data class Error(val errorMessage: ErrorMessage): Result<Nothing>()
    data class Success<out T>(val data: T): Result<T>()
}
fun <T> Result<T>.isSuccess(): Boolean = this is Result.Success<T>

fun <T> Result<T>.getErrorMessageOrNull() = when(this){
    is Result.Error -> errorMessage
    is Result.Success<*> -> null
}